package com.Monica.service;

import com.Monica.dao.UserDAO;
import com.Monica.dao.UserDAOImp;
import com.Monica.pojo.Message;
import com.Monica.pojo.User;
import com.Monica.utils.JDBCUtil;

public class UserServiceImp implements UserService{
    private UserDAO dao = new UserDAOImp();
    @Override
    public Message checkUser(String username) {
        return null;
    }

    @Override
    public Message regist(User user) {
        return null;
    }

    @Override
    public Message login(User user) {
        if (user==null || user.getUsername()==null || user.getPassword()==null){
            return new Message(false,"数据不合法！");
        }
        if (user.getUsername().equals("")||user.getPassword().equals("")){
            return new Message(false,"用户名或者密码不能为空");
        }
        User dbUser = dao.select(user.getUsername());
        if (dbUser==null){
            return new Message(false,"用户名不存在，请先进行注册！");
        }else {
            if (dbUser.getPassword().equals(user.getPassword())){
                System.out.println("恭喜，登录成功！");
                return new Message(true,"恭喜，登录成功！");

            }else {
                return new Message(false,"你输入的密码错误！");
            }
        }
    }

    @Override
    public Message changePwd(User user, String newpwd) {
        return null;
    }

    @Override
    public Message destroy(User user) {
        return null;
    }
}
